//
//  PlaceholderView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/9/17.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class PlaceholderView: UIView {
    var placeImage:UIImageView!
    override init(frame: CGRect) {
        placeImage = UIImageView()
        super.init(frame: frame)
        self.backgroundColor = Theme.BGColor
        self.addPlaceholderImage()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //添加image进来
    func addPlaceholderImage(){
        
        var hei = self.frame.size.height
        var wid = self.frame.size.width
        
        //如果是这个要加载的图片 也就是这个view的高度比较高 则用比较低的那边来计算image的宽度
        if hei>=wid{
            wid = wid/3*2
            hei = wid/1.4
        }else{
            hei = hei/3*2
            wid = hei*1.4
        }
        
        placeImage.frame.size = CGSizeMake(wid, hei)
        placeImage.center = self.center
        placeImage.image = UIImage(named: "placehoderImage")
        self.addSubview(placeImage)
    }
}
